<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*"
	pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="<%=request.getContextPath()%>/fare/css/base.css"
	rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/ligerui-icons.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery/jquery-1.8.3.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/core/base.js"></script>
	
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/fare/js/show.js"></script>--%>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/fare/lib/ligerUI/js/ligerui.min.js"></script>
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link
	href="<%=request.getContextPath()%>/fare/lib/ligerUI/skins/Aqua/css/ligerui-layout.css"
	rel="stylesheet" type="text/css" />
<link
	href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css'
	rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/fare/css/base.css"
	rel="stylesheet" type="text/css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jsFile/wait/js/wait.js"></script>	

<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript'
	src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>

<link rev="stylesheet" media="all"
	href="<%=request.getContextPath()%>/fare/css/form_style.css"
	type="text/css" rel="stylesheet">
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/jsFile/fdc.js"></script>
	<!-- 圆角文本框 -->
	<link href="<%=request.getContextPath()%>/fare/css/htc/htc.css"
		rel="stylesheet" type="text/css" />	
	<script type="text/javascript">
		$(function()
		{
			 //布局
		    $("#layout1").ligerLayout({ leftWidth: 210, height: '100%',space:2});
			var height = $(".l-layout-left").height();
			//Tab
			$("#framecenter").ligerTab({ height: height });
			 //面板
		    $("#accordionFrame").ligerAccordion({ height: height - 5, speed: null });
		    //使树结构的标头不显示
		    $(".l-accordion-header").height("0px");
		    //使左栏列表标头也不显示
		    $("#framecenter .l-tab-links").height("0px");
		    //调整右边航班信息位置
		    $("#maingrid").css("left",$("#accordionFrame").width()+7);
		    $("#layout1 .l-layout-header-toggle").click(function(){$("#maingrid").css("left",$("#accordionFrame").width()+24+7);});
		    $("#layout1 .l-layout-collapse-left-toggle").click(function(){$("#maingrid").css("left",$("#accordionFrame").width()+7);});
		});
	</script>
				
	<script type="text/javascript">
var grid;
function currentDate(){ 
    var now = new Date();       
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
    var hour = now.getHours();
    var min = now.getMinutes();
    var second = now.getSeconds();
    var today = year + "-";       
    if(month < 10)
        today += "0";       
    today += month + "-";       
    if(day < 10)
        today += "0";           
    today += day;
    today += " ";
    today += hour;
    today += ":"; 
    today += min;
    today += ":"; 
    today += second; 
    return(today); 
} 
function   formatDate(now)   {   
    var   year=now.getFullYear();   
    var   month=now.getMonth()+1;   
    var   date=now.getDate();   
    var   hour=now.getHours();   
    var   minute=now.getMinutes();   
    var   second=now.getSeconds();   
    return   year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;   
    } 
function getLocalTime(nS) {   
	   return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");    
	}      
    
$(function(){
	$('#depCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	$('#arrCity').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	if($('#grapDate').val()==''){
		$('#grapDate').val(currentDate());
	}	
	if($('#depTime').val()==''){
		$('#depTime').val(currentDate());
	}
	var grid=$("#maingrid").ligerGrid({
        enabledSort:true,    // 就否允许排序
        usePager:true,
        isScroll:true,
		columns: [
	               { display:'序号',render:function(rowData,index){
	            	   return index+1;
	               },width:40},
	               { display: '航空公司', name: 'companyName', minWidth: 110 ,isSort:false},
	               { display: '航班编号', name: 'flightNo', minWidth: 70 ,isSort:false},
				   { display: '出发地', name: 'fromCityName', minWidth: 30 ,isSort:false},
	              /*  { display: '出发地编码', name: 'fromCity', minWidth: 50 ,isSort:false}, */
	               { display: '目的地', name: 'toCityName' ,isSort:false},
	             /*   { display: '目的地编码', name: 'toCity' ,isSort:false}, */
	              
	               { display: '起飞时间', name: 'flightStartTime',width:86,type:'date',isSort:true},
	               { display: '到达时间', name: 'flightEndTime',width:86,type:'date',isSort:true,
	            	   render: function (row)
	                    {  	       		
	            		   if(row.transgerFlightNo !='' && row.transgerFlightNo != null){
	            			  return row.transferStartTime;
	            		   }else{
	            			   return row.flightEndTime;
	            		   }
	                    }},
/* 	               { display: '班次', name: 'frequence',minWidth: 50 ,isSort:true},       */
	               { display: '入库时间', name: 'entryTime',minWidth: 133,isSort:false,
	            	   render: function (row)
	                    {  	       		
	            		   if(row.entryTime !='' && row.entryTime != null){
	            			   var d = new Date(row.entryTime);   
							   return  formatDate(d);
	            		   }else{
	            			   return '';
	            		   }
	                    }} ,
	                    
/* 	               { display: '共享航班', name: 'firstShareFlight' ,isSort:false,
		 	            	   render: function (row)
			                    {  	       		
			            		   if(row.firstShareFlight == 'y'){
			            			 return '是';
			            		   }else if(row.firstShareFlight == 'n'){
			            			   return '否';
			            		   }
			                    }}, */
/*  	               { display: '中转航班(航程二航班)', columns:
	                   [
	                    { display: '中转城市', name: 'transferCityName' ,isSort:false},
	                    { display: '航班号', name: 'transgerFlightNo' ,isSort:false},
	                    { display: '起飞时间', name: 'transferStartTime' ,isSort:false},
	                    { display: '到达时间', name: 'flightEndTime' ,isSort:false,
	 	            	   render: function (row)
		                    {  	       		
		            		   if(row.transferCityName !='' && row.transferCityName != null){
		            			 return row.flightEndTime;
		            		   }else{
		            			   return '';
		            		   }
		                    }}
	                   ]
	                   } */
	              
	               ],
	     width: 'auto',pageSizeOptions: [5, 10, 20, 30], height: $(".l-layout-left").height()
	});
})
function loadGrid(data){
	var grid=$("#maingrid").ligerGrid({
			dataAction:'local',
	        enabledSort:true,    // 就否允许排序
	        data:data,
			dataType:"local"
		});
	
}

var f=false;
var code;
function loadAndDisplayData(grid,url){    
	if($('#depCity').val()!=''&&$('#arrCity').val()){
		//alert("");
		$.ajax({
	        url : url,
	        data:{
	        	'fromCityName':$('#depCity').val(),
	        	'toCityName':$('#arrCity').val(),	
 	        	'companyCode':f?code:$('#carrier').val(),
	        	'entryTime':$('#entryTime').val(),
	        	'fromCityCode':$('#depCityCode').val(),
	        	'toCityCode':$('#arrCityCode').val(),
	        	 'flightNo':$('#flightNo').val()
	        	},
	        cache : false, 
	        async : false,
	        type : "POST",
	       	complete: function(jqXHR, textStatus){
	       		if(jqXHR.status==200){
	       			//JSON Object
	       			result = parseObj(jqXHR.responseText);
	       			loadList(result);
	       			loadGrid(result); 
	       		}else{
	       			alert('查询失败,请与管理员联系');
	       		}
	       	}
	    });
	}
	FDCWait.hide();
}

var map = {};
function loadList(data){
	$("#tree").empty();
	var rows=data.Rows;//航班记录数组
	for(var i in rows){
		var has = rows[i].carrierKey in map;
		if(!has)
			map[rows[i].carrierKey]=rows[i].carrierName;
	}
	var flag=false;
	$.each(map, function(key, value) {
		flag=!flag;
		$("#tree").append("<li onclick='selectFlight(\""+key+"\")'" + " style='background-color:"+(flag?"#FFFFFF":"#F5F5F5")+"'>"+value+"</li>");			
	});
}

function selectFlight(key){
	code=key;
	f=true;
	loadAndDisplayData($('#tree'),'flightInfoQueryAction!analyse.action');
	f=false;
}

function changeAction(url){
	$('#channel').attr('action',url);
}

function checkForm(){
	if($('#depCity').val()=='中文/拼音' || $('#arrCity').val()=='中文/拼音'){
		window.confirm('航段没有选择，请选择航线!');
	        return false;
	}
	
	if($('#depCity').val()==$('#arrCity').val()){
		window.confirm('航段不能选择一样!');
        return false;
	}
	if($('#depCity').val()==''||$('#arrCity').val()==''){
		window.confirm('航段不能为空!');
        return false;
	}
	
	
	
	$("#beginDateAfterToday").val(parseInt($("#beginDateAfterToday").val()));
	
	
	$("#endDateAfterToday").val(parseInt($("#endDateAfterToday").val()));
	
	return true;
}

function checkJspForm(){

	if(!checkForm()){
		return false;
	}
 //	changeAction('flightInfoQueryAction!toAnalyseJSP.action');
	<%-- FDCWait.show(); --%>
	setTimeout(function(){loadAndDisplayData($('#tree'),'flightInfoQueryAction!analyse.action');},1);
}

</script>
</head>

<body>
	<div >
		<div class="form_table_tltle">查询条件</div>
		<form id="channel" name="channelForm" method="post"
			action="flightInfoQueryAction!analyse.action">
			<table cellSpacing=0 cellPadding=0 width="100%" border=0
				class="form_table">
				<TR>
					<TD height="26" class="left" style="text-align: left">航空公司：</TD>
					<TD><select name="vo.carrier" style="width: 150px;"
						id="carrier">
							<option value="">--------------------------------</option>
							<c:choose>
								<c:when test="${sourceLists == null}">
								</c:when>
								<c:otherwise>
									<c:forEach var="item" items="${sourceLists }">
										<c:if test="${item.webTyle==1 }">
											<c:choose>
												<c:when test="${not empty vo.carrier }">

												</c:when>
												<c:otherwise>
													<option value="${item.carrierKey}">${item.name}</option>
												</c:otherwise>

											</c:choose>


										</c:if>
									</c:forEach>
								</c:otherwise>
							</c:choose>
					</select>
					<TD class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>
 
				<TR>
					<TD width="120" height="26" class="left" style="text-align: left">航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：</TD>
					<TD><%-- <input type="text" style="width: 100px" name="vo.fromCity"
						id="depCity" value="${vo.fromCity}" readonly="readonly"> <span>至</span>
							<input type="text" style="width: 100px" name="vo.toCity"
							id="arrCity" value="${vo.toCity}" readonly="readonly"> --%>
							<jsp:include page="../inc/flightSelect.jsp">
	    <jsp:param value="${fromCity}" name="fromCity"/>
	    <jsp:param value="${fromCityCode}" name="fromCityCode"/>
	    <jsp:param value="${toCity}" name="toCity"/>
	    <jsp:param value="${toCityCode}" name="toCityCode"/>
 </jsp:include>
					<TD width="120" class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>
				<TR>
					<TD height="26" class="left" style="text-align: left">航班号：</TD>
					<TD><input  type="text" id="flightNo"
						style="width: 123px">
						
			 <!-- <font color="red">支持模糊查询</font></TD> -->
					<TD class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>
				<TR>
					<TD height="26" class="left" style="text-align: left">入库日期：</TD>
					<TD><input name="vo.depTime" type="text" id="entryTime"
						style="width: 123px" value="${vo.depTime}"
						onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd'});"
						readonly="readonly"><!--  <font color="red">*</font></TD> -->
					<TD class="left" style="text-align: left"></TD>
					<TD></TD>
				</TR>
				<TR>
					<TD class="left" style="text-align: left"></TD>
					<TD><input type="button" onclick="javascript:checkJspForm();"
						value="" class="btn01" id="Submit2" /> <input type="reset"
						onclick="resetFunction('channel')" value="" class="btn02"
						id="Submit222" /></TD>
				</TR>
			</TABLE>
		</form>

	 	<div id="layout1" style="width:99.2%; margin:0 auto;"> 
			<!-- 显示左边航空公司列表 -->
			<div position="left" title="所有航空公司" id="accordionFrame"> 
				<div title="(该标头隐藏不显示)" class="l-scroll" id="accordion1">
					<ul id="tree" style="margin-top:3px;">
					</ul>
					<br />
					<br />
				</div>
			</div>
			<!-- 显示右边航班信息列表 -->
			<div style="position:margin-top: 10px;" id="maingrid"></div>
		</div>
	</div>
</body>
</html>
<style>
<!--
.l-grid-hd-cell-text {
	text-align: center;
	cursor: text;
}
-->
</style>
